<%--
    Document   : admin
    Created on : Apr 23, 2013, 1:35:12 AM
    Author     : TNT
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="common.jsp" %>
<%@page import="RMI.Client" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
       Client client = new Client();
       boolean connect = client.Connect();
       if(connect ==false)
       out.print("<h1 align = center ><img src = 'image/sorry.jpg'> <br>Không kết nối được cơ sở dữ liệu </h1>");
       else{
           String userid="";
           String username="";
	   String email="";
	   String password="";
	   String fullname="";
           username= request.getParameter("username");
           username=replaceString(username,"'", "''");
           session.putValue("username",username);
           password= request.getParameter("password");
           password = replaceString(password, "'", "''");   
           String Admin = client.checkAdmin(username, password);
           if(Admin.equals("0")||Admin.equals("-1")||Admin.equals("-2")||Admin.equals("")){
               session.putValue("username", Admin);
               response.sendRedirect("admin.jsp");
           }
           else{
               String Info[] = Admin.split("###");
               session.putValue("username", Info[0]);
               session.putValue("password", Info[1]);
               session.putValue("name", Info[2]);
               session.putValue("phone", Info[3]);
               session.putValue("email", Info[4]);
               response.sendRedirect("index.jsp");
           }
       }
        
        
	
%>
</body>
</html>